﻿namespace Bowlus.FrontEnd
{
    using Bowlus.Common;
    using Bowlus.FrontEnd.RequestRouting;
    using Bowlus.FrontEnd.RequestRouting.ApplicationDeployment;
    using Bowlus.FrontEnd.RequestRouting.ApplicationRequestRouting;
    using Bowlus.FrontEnd.RequestRouting.BlobLeaseUtil;

    using Microsoft.Practices.Unity;
    using Microsoft.Web.Administration;
    using Microsoft.WindowsAzure.ServiceRuntime;

    public static class ContainerBootstrapper
    {
        public static void RegisterTypes(IUnityContainer container)
        {
            CommonContainerBootstrapper.RegisterCommonDependencies(container);

            container.RegisterType<IRoutingConfigManager, ArrConfigManager>(
                new ContainerControlledLifetimeManager(),
                new InjectionConstructor(
                    new ServerManager(), RoleEnvironment.CurrentRoleInstance.Id + "_AppFrontend"));

            container.RegisterType<IBlobLease, BlobLease>(
                new ContainerControlledLifetimeManager(),
                new InjectionConstructor(RoutingManager.DefaultLeaseBlobName));

            container.RegisterType<IApplicationDeploymentStrategy, BasicDeploymentStrategy>();

            container.RegisterInstance(typeof(RoutingManager), new ContainerControlledLifetimeManager());
        }
    }
}